function getLevel(arr) {
    if(!(arr instanceof Array)) {
        return 0
    }
    let max = 1
    const dfs = (arr, level) => {
        for(let item of arr) {
            if(item instanceof Array) {
                const itemVal = dfs(item, level+1)
                if(itemVal > max) {
                    max = itemVal
                }
            }
        }
        return level > max ? level : max
    }   
   return dfs(arr, 1)
}

const arr = [1,2,[1,2,[3]], 1, [1,2,[5, [8]]]]
console.log(getLevel(arr));